package com.zecan.rabbitmq.rabbitmq.service;

import com.zecan.rabbitmq.rabbitmq.config.PriorityConfig;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: lenovo
 * \* Date: 2022/4/21
 * \* Time: 12:17
 * \* Description:
 * \
 */
@Component
public class PriorityConsumer {

    @RabbitListener(queues = PriorityConfig.PRIORITY_QUEUE_NAME)
    public void listenerPriority(Message message) {
        byte[] body = message.getBody();
        MessageProperties mps = message.getMessageProperties();
        System.out.println("接受到消息来自交换机: 【" + mps.getReceivedExchange() + "】, " +
                "队列：【" + mps.getConsumerQueue() + "】：\n内容: " + new String(body));
    }
}
